package com.xinqi.modules.prepare.prepare.manager;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.mybatis.data.service.BaseService;
import com.xinqi.modules.prepare.prepare.domain.PrepareEntity;
import com.xinqi.modules.prepare.prepare.domain.PrepareMemberEntity;
import com.xinqi.modules.prepare.prepare.dto.req.PrepareMemberQueryDTO;
import com.xinqi.modules.prepare.prepare.dto.rsp.PrepareMemberResultDTO;
import com.xinqi.modules.prepare.prepare.enums.PrepareMemberRoleEnum;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 备课区成员管理层
 *
 * @author: system
 * @date: 2023/03/19
 */
public interface PrepareMemberManager extends BaseService<PrepareMemberEntity> {

    /**
     * 自定义分页查询
     */
    Page<PrepareMemberResultDTO> findPage(Page<Object> page, PrepareMemberQueryDTO query);

    /**
     * 自定义列表查询
     */
    List<PrepareMemberResultDTO> findList(PrepareMemberQueryDTO query);

    /**
     * 根据id查询 备课区成员数据
     */
    PrepareMemberEntity findById(Long id);

    /**
     * 根据id删除 备课区成员数据
     */
    @Transactional(rollbackFor = Exception.class)
    boolean deleteById(Long id);

    PrepareMemberEntity findByPrepareIdAndUserId(Long prepareId, Long userId);

    boolean existByPrepareIdAndUserId(Long prepareId, Long userId);

    @Transactional(rollbackFor = Exception.class)
    Boolean deleteByIds(Long prepareId, List<Long> ids);

    @Transactional(rollbackFor = Exception.class)
    void addLeader(PrepareEntity prepare);

    @Transactional(rollbackFor = Exception.class)
    void addLeader(Long prepareId, Long userId);

    long countByPrepareId(Long prepareId, PrepareMemberRoleEnum role);

    long countByUserId(Long userId, PrepareMemberRoleEnum role);
}
